//
//  CGFileReportCell.m
//  SchoolClient
//
//  Created by mac on 15/11/19.
//  Copyright © 2015年 mac. All rights reserved.
//

#import "CGFileReportCell.h"

@implementation CGFileReportCell

@synthesize titleLabel,timeLabel;

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //招聘标题
        CGRect aFrame = CGRectMake(10, 15, SCREEN_WIDTH - 20, 24);
        titleLabel = [[UILabel alloc]initWithFrame:aFrame];
        titleLabel.text = @"春季校园人才招聘会";
        titleLabel.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:titleLabel];
        
        //招聘时间
        aFrame.origin.y += 40;
        timeLabel = [[UILabel alloc]initWithFrame:aFrame];
        timeLabel.text = @"Nov 10, 2015 3:35:36 PM";
        timeLabel.font = [UIFont systemFontOfSize:15];
        timeLabel.textColor = [UIColor darkGrayColor];
        [self.contentView addSubview:timeLabel];
        
        
    }
    return self;
}



-(void)setFileReport:(CGFileService *)fileReport{
    _fileReport = fileReport;
    titleLabel.text = fileReport.title;
    timeLabel.text = [self getTimeWithDate:fileReport.time];

}


-(NSString *)getTimeWithDate:(NSString *)timeStr{
    
    NSDateFormatter *inputFormatter = [[NSDateFormatter alloc]init];
    NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@"en_US"];
    [inputFormatter setLocale:locale];
    [inputFormatter setDateFormat:@"MMM dd, yyyy hh:mm:ss aa"];
    NSDate *inputDate = [inputFormatter dateFromString:timeStr];
    //创建日期模板对象,设置模板的显示格式
    NSDateFormatter *outputFormatter = [[NSDateFormatter alloc]init];
    //outputFormatter.dateFormat = @"yyyy-MM-dd HH:mm";
    outputFormatter.dateFormat = @"yyyy-MM-dd";
    NSString *outputDate = [outputFormatter stringFromDate:inputDate];     //自动转换成当地时间
    return outputDate;
}


@end
